Server_Detected = call compile preprocessFile "scripts\common.sqf";

private ["_veh", "_iconName", "_vehName", "_vehType", "_markerPos", "_markerObj"];

_iconName = "";
If (typename(_this) == "ARRAY") then {
	_veh = _this select 0;
	If (count _this > 1) then {
		_iconName = _this select 1;
	};
} else {
	_veh = _this;
};
If (isnil("_veh")) exitwith {};

_vehName = vehicleVarName _veh;
_vehType = typeof _veh;

_vehName = Format["%1_%2",_vehType, _vehName];

diag_log Format["Setting follow up icon on vehicle %1 (%2)", _vehType, _vehName];

_markerPos = getMarkerPos _vehName;
If (((_markerPos select 0) == 0) && ((_markerPos select 1) == 0) && ((_markerPos select 2) == 0)) then {
	_markerObj = createMarker [_vehName, getPos _veh];
	_vehName setMarkerShape "ICON";
	_vehName setMarkerType "b_inf";
	_vehName setMarkerColor "ColorBlue";
	_vehName setMarkerText _iconName;
	switch (true) do {
		case (_veh isKindOf "Car"): {
			_vehName setMarkerType "b_motor_inf";
		};
		case (_veh isKindOf "Motorcycle"): {
			_vehName setMarkerType "b_motor_inf";
		};
		case (_veh isKindOf "Wheeled_APC"): {
			_vehName setMarkerType "b_mech_inf";
		};
		case (_veh isKindOf "Tank"): {
			_vehName setMarkerType "b_armor";
		};
		case (_veh isKindOf "Helicopter"): {
			_vehName setMarkerType "b_air";
		};
		case (_veh isKindOf "Plane"): {
			_vehName setMarkerType "b_plane";
		};
	};
	diag_log Format["Marker Follow up is created"];
};

while { (alive _veh) } do {
		_vehName setMarkerPos getpos _veh;
		If ((speed _veh) <= 0.2) then {
			Sleep 30;
		} else {
			Sleep 5;
		};
};